package com.hjxr.quota.theme.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.hjxr.quota.valid.AddGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Data
@ApiModel
@TableName("quota_theme_set")
@KeySequence(value = "seq_quota_theme_set", clazz = Integer.class)
public class QuotaThemeSet extends Model<QuotaThemeSet> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.INPUT)
    @Null(message = "新增不可指定ID", groups = {AddGroup.class})
    @ApiModelProperty(value = "主键")
    private Integer id;
    @NotNull(message = "主题集标题不能为空", groups = {AddGroup.class})
    @ApiModelProperty(value = "标题")
    private String setTitle;
    @ApiModelProperty(value = "描述")
    private String setDescription;
    @ApiModelProperty(value = "主题域id")
    @NotNull(message = "主题域ID不能为空", groups = {AddGroup.class})
    private Integer zoneId;
    private String createBy;
    private Date createDate;
    @ApiModelProperty(value = "父主题集id")
    private Integer parentId;
    @ApiModelProperty(value = "是否主题  废弃")
    private Boolean isTheme;
    @ApiModelProperty(value = "排序字段")
    @NotNull(message = "排序不能为空", groups = {AddGroup.class})
    @Min(value = 0, message = "排序必须大于等于0", groups = {AddGroup.class})
    private Integer orderNum;
    @ApiModelProperty(value = "主题集子节点")
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<QuotaThemeSet> children;
    @ApiModelProperty(value = "主题域标题")
    @TableField(exist = false)
    private String zoneTitle;
    @ApiModelProperty(value = "唯一键")
    @TableField(exist = false)
    private String uuid;
    @ApiModelProperty(value = "类型")
    @TableField(exist = false)
    private String category;

    public String getUuid() {
        return UUID.randomUUID().toString();
    }

    public String getZoneTitle() {
        return setTitle;
    }
}
